# -*- encoding=utf8 -*-
__author__ = "Az007"
import logging
logger = logging.getLogger("airtest")
logger.setLevel(logging.ERROR)
from airtest.core.api import *
auto_setup(__file__)
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)


data = {'阿泽同学': '9999999999', 
        'div.谭': '10001', 
        'Excel 贴吧': '10086'}


    # 添加备注
def tjbz(name,sjhm):    
    poco(text=name).long_click()
    poco(text="设置备注和标签").click()
    poco(text="添加").click()
    poco("com.tencent.mm:id/hv4").set_text(sjhm)
    poco(text="完成").click()
    
while True:

    
    s = poco("android.widget.FrameLayout").offspring("com.tencent.mm:id/fj1").child("android.widget.FrameLayout").offspring("com.tencent.mm:id/e_a")[1].offspring("com.tencent.mm:id/gv2").child("android.widget.FrameLayout").child("android.widget.FrameLayout")[0].child("android.widget.LinearLayout").offspring("com.tencent.mm:id/js").child("android.widget.LinearLayout")[1].offspring("com.tencent.mm:id/bqy").offspring("com.tencent.mm:id/hg4").get_text()
    print(s)

    if (data.get(s)):
        tjbz(s,data.get(s))
        swipe((250,700),(293,300))

    else:
        swipe((250,700),(293,300))
